import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    //创建树的节点
    static class TreeNode{
        char val;
        TreeNode left;
        TreeNode right;
        public TreeNode(char val){
            this.val = val;
        }
    }
    public static int index = 0;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            TreeNode root = createTree(str);
            inorderTree(root);
            System.out.println();
        }
    }

    public static void inorderTree(TreeNode root){
        if(root == null){
            return;
        }
        inorderTree((root.left));
        System.out.print(root.val);
        inorderTree(root.right);
    }

    public static TreeNode createTree(String str){
        TreeNode root = null;
        if(str.charAt(index) != '#'){
            root = new TreeNode(str.charAt(index));
            index++;
            root.left = createTree(str);
            root.right = createTree(str);
        }else{
            index++;
        }
        return root;
    }
}